"use strict";
exports.__esModule = true;
exports.formatDate = exports.generateArray = void 0;
var generateArray = function (start, end, callback) {
    var array = [];
    for (var index = start; index <= end; index++) {
        array.push(callback(index));
    }
    return array;
};
exports.generateArray = generateArray;
var DateFormatMap = /** @class */ (function () {
    function DateFormatMap() {
    }
    return DateFormatMap;
}());
/**
 * @description: 格式化时间
 * @param {Date} date
 * @param {string} fmt "yyyy-MM-dd hh:mm:ss:S q"
 * @return {string}
 */
var formatDate = function (date, fmt) {
    date = new Date(date);
    if (isNaN(date.valueOf()))
        return "";
    var o = {
        "M+": date.getMonth() + 1, //月份
        "d+": date.getDate(), //日
        "h+": date.getHours(), //小时
        "m+": date.getMinutes(), //分
        "s+": date.getSeconds(), //秒
        "q+": Math.floor((date.getMonth() + 3) / 3), //季度
        S: date.getMilliseconds() //毫秒
    };
    var regRes = new RegExp("y+").exec(fmt);
    if (regRes?.length) {
        fmt = fmt.replace(regRes[0], date
            .getFullYear()
            .toString()
            .substring(4 - regRes[0].length));
    }
    for (var k in o) {
        var regRes = new RegExp(k).exec(fmt);
        if (regRes?.length) {
            fmt = fmt.replace(regRes[0], regRes[0].length === 1
                ? o[k]
                : ("00" + o[k]).substring(o[k].toString().length));
        }
    }
    return fmt;
};
exports.formatDate = formatDate;